/*
 * Author: vyouzhi <vyouzhi@163.com>
 * http://www.xda.cn
 *
 * File: convey.c
 * Create Date: 2011-07-13 13:42:09
 *
 */
#include <unistd.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

#include "conf_lib.h"
#include "convey_lib.h"
#include "convey.h"

int main(int argc, char* argv[]){
	int h, cp = 0;
	long id;
	long cs = 0, cg = 0, ig = 0, is = 0;
	char *ch;
	conf_init();

	if(argc < 2) {
		exit(0);
	}

	while((h = getopt(argc, argv, "t:g:s:h:p:?")) != -1){
		switch(h){
			case 't':
				printf("option t: %s\n", optarg);
				id = atol(optarg);
				tell_all_client_update(id);
				break;
			case 'g':
				cg = atol(optarg);
				ig = 1;
				break;
			case 's':
				cs = atol(optarg);
				is = 1;
				break;
			case 'h':
				ch = optarg;
				break;
			case 'p':
				cp = atoi(optarg);
				break;
			case '?':
			default:
				printf("convey --help\n");
				exit(-1);
		}
	}
	
	if(ig && ch != NULL && cp != 0){
		getlog(cg, ch, cp);
		exit(-1);
	}

	if(is && ch != NULL && cp != 0){
		doingupdate(cs, ch, cp);
	}	
    return 0;
}
/* vim: set ts=4 sw=4: */

